package com.tencent.iov.cowin.befsale.clue.controller.clue;

import com.tencent.iov.cowin.befsale.clue.controller.clue.assembler.ClueTodoRelAssembler;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.AddClueTodoRelRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.DeleteClueTodoRelRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.QueryClueTodoRelRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.request.UpdateClueTodoRelRequest;
import com.tencent.iov.cowin.befsale.clue.controller.clue.vo.response.ClueTodoRelResponse;
import com.tencent.iov.cowin.befsale.clue.domain.clue.po.ClueTodoRel;
import com.tencent.iov.cowin.befsale.clue.service.clue.ClueTodoRelService;
import com.software.boot.common.entity.Response;
import com.software.boot.common.model.dao.PageRequest;
import com.software.boot.common.model.dao.PageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Describe: 线索代办关联表_Controller层
 * @author: zhiye.wang
 * @created: 2022-02-11 14:45:49
 * @version: 1.0
 */
@RestController
@RequestMapping(value = "/v1/demo/clueTodoRel", produces = MediaType.APPLICATION_JSON_VALUE)
@Api(tags = "线索代办关联表_Controller层")
public class ClueTodoRelController{
	
	@Autowired
	private ClueTodoRelService clueTodoRelService;

	/**
	 * 通过ID获取详细信息
	 *
	 * @param: id
	 * @return: ClueTodoRel对象
	 */
	@ApiOperation(value = "ClueTodoRel管理-通过ID获取详细信息接口", httpMethod = "GET", response = Response.class, notes = "get_detail_by_id")
	@GetMapping(path = "/get_detail_by_id")
	public Response<ClueTodoRelResponse> getDetailById(@ApiParam(required = true, value = "对象ID", defaultValue = "1")  @RequestParam("id") Long id) {
		return Response.success(ClueTodoRelAssembler.transformPOToResponseVo(clueTodoRelService.getDetailById(id), ClueTodoRelResponse.class));
	}

	/**
	 * 单条数据插入ClueTodoRel
	 * @param request
	 * @return 插入的条数
	 */
	@ApiOperation(value = "ClueTodoRel管理-添加信息接口", httpMethod = "POST", response = Response.class, notes = "add")
	@PostMapping(path = "/add")
	public Response<Integer> add(@Valid @RequestBody AddClueTodoRelRequest request) {
		return Response.success(clueTodoRelService.insert(ClueTodoRelAssembler.transformVOToPO(request, ClueTodoRel.class)));
	}

	/**
	 * 批量插入ClueTodoRel
	 * @param requests
	 * @return 批量插入的条数
	 */
	@ApiOperation(value = "ClueTodoRel管理-批量插入ClueTodoRel接口", httpMethod = "POST", response = Response.class, notes = "add_batch")
	@PostMapping(path = "/add_batch")
	public Response<Integer> addBatch(@Valid @RequestBody List<QueryClueTodoRelRequest> requests) {
		return Response.success(clueTodoRelService.insertBatch(ClueTodoRelAssembler.transformPOToResponseVoList(requests, ClueTodoRel.class)));
	}

	/**
	 * 通过ID修改信息接口
	 *
	 * @param: request
	 * @return: 修改的条数
	 */
	@ApiOperation(value = "ClueTodoRel管理-修改信息接口", httpMethod = "POST", response = Response.class, notes = "update")
	@PutMapping(path = "/update")
	public Response<Integer> update(@Valid @RequestBody UpdateClueTodoRelRequest request) {
		return Response.success(clueTodoRelService.update(ClueTodoRelAssembler.transformVOToPO(request, ClueTodoRel.class)));
	}

	/**
	 * 通过ID删除数据
	 * @param request
	 * @return 删除的条数
	 */
	@ApiOperation(value = "ClueTodoRel管理-通过ID删除接口", httpMethod = "POST", response = Response.class, notes = "delete")
	@DeleteMapping(path = "/delete")
	public Response<Integer> delete(@Valid @RequestBody DeleteClueTodoRelRequest request) {
		return Response.success(clueTodoRelService.delete(ClueTodoRelAssembler.transformVOToPO(request, ClueTodoRel.class)));
	}

	/**
	 * 根据条件查询对象list列表
	 * @param request
	 * @return 查询结果
	 */
	@ApiOperation(value = "ClueTodoRel管理-根据条件查询对象list列表接口", httpMethod = "POST", response = Response.class, notes = "query_list_by_param")
	@PostMapping(path = "/get_list_by_param")
	public Response<List<ClueTodoRelResponse>> getListByParam(@RequestBody QueryClueTodoRelRequest request) {
		List<ClueTodoRel> responseList = clueTodoRelService.getListByParam(ClueTodoRelAssembler.transformVOToPO(request, ClueTodoRel.class));
		return Response.success(ClueTodoRelAssembler.transformPOToResponseVoList(responseList, ClueTodoRelResponse.class));
	}

	/**
	 * 根据条件查询对象Page记录
	 * @param request
	 * @return 查询结果
	 */
	@ApiOperation(value = "ClueTodoRel管理-根据条件查询对象Page记录接口", httpMethod = "POST", response = Response.class, notes = "get_page_by_param")
	@PostMapping(value = "/get_page_by_param")
	public Response<PageResponse<ClueTodoRelResponse>> getPageByParam(@RequestBody PageRequest<QueryClueTodoRelRequest> request) {
		PageResponse<ClueTodoRel> clueTodoRelPageResponse = clueTodoRelService.getPageByParam(ClueTodoRelAssembler.transformVOToPOPage(request, ClueTodoRel.class));
		return Response.success(ClueTodoRelAssembler.transformPOToResponseVoPage(clueTodoRelPageResponse, ClueTodoRelResponse.class));
	}

	/**
	 * 根据条件查询单个对象
	 * @param request
	 * @return 查询结果
	 */
	@ApiOperation(value = "ClueTodoRel管理-根据条件查询单个对象接口", httpMethod = "POST", response = Response.class, notes = "get_page_by_param")
	@PostMapping(value = "/get_one_by_param")
	public Response<ClueTodoRelResponse> getOneByParam(@RequestBody QueryClueTodoRelRequest request){
		ClueTodoRel clueTodoRel = clueTodoRelService.getOneByParam(ClueTodoRelAssembler.transformVOToPO(request, ClueTodoRel.class));
		return Response.success(ClueTodoRelAssembler.transformPOToResponseVo(clueTodoRel, ClueTodoRelResponse.class));
	}
}